package org.zxp.designpattern.singleton.practise;

/**
 * @program: effectiveJava
 * @description:
 * @author: X-Pacific zhang
 * @create: 2019-11-27 09:46
 **/
public class StaticClass {
    private static class StaticClassHolder{
        private static final StaticClass INSTANCE = new StaticClass();
    }

    private final Object o1;

    private StaticClass(){
        o1 = new Object();
    }

    public static StaticClass getInstance(){
        return StaticClassHolder.INSTANCE;
    }

    public void print(){
        System.out.println(o1.hashCode());
    }
}
class Test2{
    public static void main(String[] args){
        StaticClass staticClass = StaticClass.getInstance();
        staticClass.print();
        StaticClass staticClass2 = StaticClass.getInstance();
        staticClass2.print();
//        System.out.println(new Object().hashCode());
    }
}